
import 'package:flutter/material.dart';

class WyWrap extends StatefulWidget {
  const WyWrap({Key? key}) : super(key: key);

  @override
  _WyWrapState createState() => _WyWrapState();
}

class _WyWrapState extends State<WyWrap> {
  int index =1;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Wrap'),),
      body:index==1?_createWrap1() :Wrap(
        direction: Axis.horizontal,
        alignment: WrapAlignment.spaceBetween,
        children: List.generate(10, (i) {
          double w = 50.0 + 10 * i;
          return Container(
            color: Colors.primaries[i],
            height: 50,
            width: w,
          );
        }),
      ),
    );
  }
  _createWrap1(){
    return Wrap(
      spacing: 5,
      runSpacing: 3,
      crossAxisAlignment: WrapCrossAlignment.center,
      children: List.generate(10, (i) {
        double w = 50.0 + 10 * i;
        double h = 50.0 + 5 * i;
        return Container(
          color: Colors.primaries[i],
          height: h,
          alignment: Alignment.center,
          width: w,
          child: Text('$i'),
        );
      }),
    );
  }
}
